#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/random.hpp>
#include <boost/random/linear_congruential.hpp>
using namespace boost;

#include <iostream>
using namespace std;

#include <ctime>
//#include <sys/time.h>

/*double gettimeofday_sec()
{
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return tv.tv_sec + (double)tv.tv_usec*1e-6;
  }*/


void test( unsigned int N, unsigned int M, unsigned int seed)
{
  typedef adjacency_list<setS,vecS,directedS> graph_t;

  clock_t start, finish;
  //double start, finish;

  graph_t g;
  boost::minstd_rand gen( seed);
  
  start =clock();
  //start =gettimeofday_sec();
  generate_random_graph( g, N, M, gen
			 , false // allow_parallel
			 , false // self_edges
			 );
  finish =clock();
  //finish =gettimeofday_sec();
  std::cout <<(double)(finish - start)/(double)CLOCKS_PER_SEC 
	    <<std::endl;
  //std::cout <<finish - start <<std::endl;
}

int main( int argc, char* argv[])
{
  unsigned int N;
  unsigned int M;
  unsigned int seed =1;
  
  if ( argc ==3){
    N =atoi( argv[1]);
    M =atoi( argv[2]);
  }
  else if( argc ==4){
    N =atoi( argv[1]);
    M =atoi( argv[2]);
    seed =atoi( argv[3]); 
  }
  else {
    std::cerr <<"usage: random nodes edges seed" <<std::endl;
    exit( 1);
  }
  
  test( N, M, seed);
  
  return 0;
}

